import { getCurrentInstance } from '@tarojs/taro';
import { useState, useEffect } from "react";
import { View } from "@tarojs/components";
import Header from "@/components/header";
import Return from '@/components/Return';
import Loading from '@/components/loading';
import { getAnnouncementDetail } from "@/api/message";
import css from './index.module.less';

export default function AnnouncementDetails() {
    const [visible, setVisible] = useState(true);
    const router = getCurrentInstance().router.params;
    const [detail, setDetail] = useState({});
    useEffect(() => {
        getAnnouncementDetail(router.id).then((res) => {
            if (res.code === 200){
                setDetail(res.data);
                setVisible(false);
            }
        });
    }, []);
    return (
        <View className={css.app}>
            <Header message='系统公告' left='140px' />
            <Return />
            <Loading visible={visible} />
            {visible ? <View /> : <View className={css.content}>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{detail.content}
                <View className={css.bottom}>
                    记录人员：{detail.publisher}
                    <View></View>
                    记录时间: {detail.publishedTime}
                </View>
            </View>}
        </View>
    );
}
